What is fancy-log?
The fancy-log package is designed for logging messages in Node.js applications with timestamps. It's particularly useful for development environments where tracking the timing of various operations is crucial. The package provides a simple API to prepend a timestamp to your log messages, making it easier to follow the flow of operations and debug issues related to timing.
What are fancy-log's main functionalities?
Basic Logging
This feature allows you to log any message with a timestamp. It's the fundamental functionality of fancy-log, making it straightforward to add time-stamped logging to your application.
const log = require('fancy-log');
log('Hello, world!');
Other packages similar to fancy-log
winston
Winston is a multi-transport async logging library for Node.js. Compared to fancy-log, winston offers more flexibility and features such as logging levels (info, warn, error, etc.), multiple storage options (console, file, HTTP, etc.), and custom formatting. It's more suitable for complex applications that require detailed logging configurations.
morgan
Morgan is an HTTP request logger middleware for Node.js, designed to log requests in web applications. While fancy-log focuses on general-purpose logging with timestamps, morgan specializes in logging HTTP requests, providing insights into the traffic your web application handles. It's a better choice for web applications that need to monitor HTTP activity.
debug
Debug is a tiny Node.js debugging utility modeled after Node core's debugging technique. It allows you to debug your application in a more granular way by enabling/disabling specific sections of logging output. Unlike fancy-log, which is more about timestamped logging, debug is focused on conditional logging based on the environment, making it ideal for development and debugging purposes.
fancy-log
Log things, prefixed with a timestamp.
Usage
var log = require('fancy-log');
log('a message');
log.error('oh no!');
API
log(msg...)
Logs the message as if you called console.log
but prefixes the output with the
current time in HH:MM:ss format.
log.error(msg...)
Logs the message as if you called console.error
but prefixes the output with the
current time in HH:MM:ss format.
log.warn(msg...)
Logs the message as if you called console.warn
but prefixes the output with the
current time in HH:MM:ss format.
log.info(msg...)
Logs the message as if you called console.info
but prefixes the output with the
current time in HH:MM:ss format.
log.dir(msg...)
Logs the message as if you called console.dir
but prefixes the output with the
current time in HH:MM:ss format.
License
MIT